package com.chinaums.fsp.sdk.request;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.junit.Test;

import com.google.gson.Gson;

/**
 * 开户异步通知回调测试
 * @author hty
 *
 */
public class OpenAccountCallBackTest {
	
	
	@Test
	public void testCallBack(){
		String result = "";
		String url = "http://127.0.0.1:8083/pgt-api/api/v1/draft/callback/customer/regist";
		
		Map<String,String> map = new HashMap<String,String>();
		map.put("serialNo", "2019101016402656580080100000000005600000000");
		map.put("certId", "931310201785049785");
		map.put("createState", "2");
		map.put("rejectReason", "");
        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
        Gson gson = new Gson();
        HttpPost httpPost = new HttpPost(url);
        httpPost.setHeader("Content-Type","application/json;charset=utf-8");
        httpPost.setHeader("Accept","application/json");
        try {
            httpPost.setEntity(new StringEntity(gson.toJson(map),"utf-8"));
            HttpResponse response = httpclient.execute(httpPost);
            result = EntityUtils.toString(response.getEntity());
        } catch (IOException e) {
            e.printStackTrace();
        }
		System.out.println(result);
	}
}

